package com.wanjia.bpsapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanjia.bpsapi.mapper.WjSupplierMapper;
import com.wanjia.bpsapi.pojo.entity.WjProductOffer;
import com.wanjia.bpsapi.mapper.WjProductOfferMapper;
import com.wanjia.bpsapi.pojo.entity.WjStoreProduct;
import com.wanjia.bpsapi.pojo.entity.WjSupplier;
import com.wanjia.bpsapi.service.IWjProductOfferService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 商品报价表---二次升级 服务实现类
 * </p>
 *
 * @author wyn
 * @since 2023-02-13
 */
@Service
public class WjProductOfferServiceImpl extends ServiceImpl<WjProductOfferMapper, WjProductOffer> implements IWjProductOfferService {

    @Autowired
    WjProductOfferMapper wjProductOfferMapper;

    @Autowired
    WjSupplierMapper wjSupplierMapper;

    @Override
    public int addProductOffer(WjProductOffer wjProductOffer) {
        /*Integer id = wjProductOffer.getId();
        WjProductOffer data = wjProductOfferMapper.selectById(id);
        if (data !=null){
            wjProductOfferMapper.deleteById(data.getId());
        }*/
        //wjProductOfferMapper.delete(new QueryWrapper<>());
        int i = wjProductOfferMapper.insert(wjProductOffer);
        return i;
    }

    @Override
    public List<String> getBaseID() {
        QueryWrapper wrapper =new QueryWrapper();
        List<WjSupplier> list = wjSupplierMapper.selectList(wrapper);
        ArrayList<String> idlist =new ArrayList();
        for (WjSupplier wjSupplier : list) {
            Integer id = wjSupplier.getId();
            idlist.add(id.toString());
        }
        System.out.println(idlist);
        return idlist;
    }
}
